home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
doom
/
turric03.zip
/
TURRIC03.ZIP
/
PROGS
/
FLAMER.QC
< prev
next >
Wrap
Text File
|
1997-02-06
|
7KB
|
318 lines
/*
==============================================================================
FLAMETHROWER
==============================================================================
*/
// prototypes
float() crandom;
void(entity burnee) SpawnFlame2;
void() bubble_bob;
/*
================
FlameDie
================
Function for the death of a flame.
*/
void () FlameDie =
{
local float rn;
rn = random();
// 30% die out, 40% keep going, 30% spread. Flames always die out for zombies.
if(rn <= 0.3 || self.owner.classname == "zombie")
{
self.owner.onfire = self.owner.onfire - 1;
SUB_RemoveTempEnt();
}
else
{
self.alivetime = time + 5;
if(rn > 0.7)
{
SpawnFlame2(self.owner);
}
}
};
/*
================
Burn
================
Think function for flames burning on an entity.
*/
void () Burn =
{
local vector height_v;
local float height_f;
local float rn;
// Set next time to think.
self.nextthink = time + 0.1;
self.think = Burn;
if(self.owner.onfire <= 0)
{
self.owner.onfire = 0;
SUB_RemoveTempEnt();
return;
}
// Check if flame has been extinguished.
if((self.owner.waterlevel >= 2 || self.waterlevel >= 2) && self.owner.watertype != CONTENT_LAVA)
{
sound (self.owner, CHAN_WEAPON, "player/slimbrn2.wav", 1, ATTN_NORM);
self.owner.effects = self.owner.effects - (self.owner.effects & EF_BRIGHTLIGHT);
self.owner.onfire = self.owner.onfire - 1;
SUB_RemoveTempEnt();
// Message to player.
if(self.owner.classname == "player")
{
sprint(self.owner, "You put yourself out\n");
}
return;
}
if(self.burncounter >= 10)
{
// Make burning sound.
rn = random();
if((rn <= 0.5) && (time > self.wait))
{
sound (self, CHAN_WEAPON, "weapons/flame.wav", 0.7, ATTN_NORM);
self.wait = time + 1;
}
// Cause damage to owning entity.
T_Damage (self.owner, self, self, FLAME_DAMAGE);
self.burncounter = 0;
// Warning message to player.
if(self.owner.classname == "player")
{
sprint(self.owner, "You are on fire!\n");
}
}
self.burncounter = self.burncounter + 1;
// Check if it's time to die out.
if(time > self.alivetime)
{
FlameDie();
return;
}
// Check height of flame and reset if too high.
height_v = self.origin - self.owner.origin;
height_f = vlen(height_v);
if(height_f >= 40)
{
setorigin (self, self.owner.origin + self.base_point);
}
self.velocity_x = 80 * crandom();
self.velocity_y = 80 * crandom();
self.velocity_z = 300 * random();
};
/*
================
Flame2Touch
================
Touch function for the flames burning on an entity.
*/
void () Flame2Touch =
{
local float rn;
if(other == world)
return;
if((other != self.owner) && (other.onfire < 5))
{
// The fire spreads 50% of the time.
rn = random();
if( rn <= 0.5)
{
other.onfire = other.onfire + 1;
SpawnFlame2(other);
}
}
};
/*
================
SpawnFlame2
================
Spawn a flame that burns on an entity.
*/
void(entity burnee) SpawnFlame2 =
{
local entity flame;
// To prevent packet overflows from too many flames being created.
if (current_temp_entities >= MAX_TEMP_ENTITIES)
{
return;
}
else
{
current_temp_entities = current_temp_entities + 1;
flame = spawn();
flame.owner = burnee;
flame.movetype = MOVETYPE_FLYMISSILE;
flame.solid = SOLID_BBOX;
flame.classname = "flame2";
flame.touch = Flame2Touch;
flame.nextthink = time + 0.1;
flame.think = Burn;
setmodel (flame, "progs/flame2.mdl");
setsize (flame, '0 0 0', '0 0 0');
flame.alivetime = time + 5;
// Base point to burn above.
flame.base_point = crandom() * '15 0 0' + crandom() * '0 15 0'+ crandom() * '0 0 15';
setorigin (flame, burnee.origin + flame.base_point);
flame.velocity_x = 80 * crandom();
flame.velocity_y = 80 * crandom();
flame.velocity_z = 300 * random();
flame.avelocity = '0 0 0';
}
};
/*
================
Flame1Touch
================
Touch function for the flames fired from the flame unit.
*/
void () Flame1Touch =
{
local float rn;
if (other.takedamage)
{
// 50% chance of flame catching the touched entity on fire.
// If entity not already at maximum combustion level.
rn = random();
if ((rn <= 0.5) && (other.onfire < 5))
{
// Make the entity more on fire.
other.onfire = other.onfire + 1;
other.effects = other.effects + (other.effects & EF_BRIGHTLIGHT);
SpawnFlame2(other);
}
// Damage the touched entity.
T_Damage (other, self, self.owner, FLAME_DAMAGE);
// Remove self.
SUB_RemoveTempEnt();
}
else
{
// If hit a non damagable entity.
self.velocity = '0 0 0';
self.velocity_z = random()*24 + 24;
}
};
/*
================
FlamerBubbles
================
Fire a flame from the flame unit.
*/
void() FlamerBubble =
{
local entity bubble;
if (self.waterlevel != 3)
return;
// To prevent packet overflows from too many flames being created.
if (current_temp_entities >= MAX_TEMP_ENTITIES)
{
return;
}
else
{
current_temp_entities = current_temp_entities + 1;
current_flame_bubbles = current_flame_bubbles + 1;
bubble = spawn();
setmodel (bubble, "progs/s_bubble.spr");
setorigin (bubble, self.origin + v_forward * 40);
bubble.movetype = MOVETYPE_NOCLIP;
bubble.solid = SOLID_NOT;
bubble.velocity = '0 0 15';
bubble.classname = "flamer_bubble";
bubble.nextthink = time + 0.5;
bubble.think = bubble_bob;
bubble.frame = 0;
bubble.cnt = 0;
setsize (bubble, '-8 -8 -8', '8 8 8');
}
};
/*
================
W_FireFlame
================
Fire a flame from the flame unit.
*/
void() W_FireFlame =
{
local entity flame;
local float rn;
// To prevent packet overflows from too many flames being created.
if (current_temp_entities >= MAX_TEMP_ENTITIES)
{
sprint(self, "fuel blockage in flame unit\n");
return;
}
// Rocket fuel usage
self.rocket_fuel = self.rocket_fuel - 1;
if (self.rocket_fuel <= 0)
{
self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
self.rocket_fuel = 3;
}
// If attempt to fire the flame unit under water.
if (self.waterlevel > 2)
{
FlamerBubble();
rn = random();
if (rn < 0.5)
sound (self, CHAN_WEAPON, "misc/water1.wav", 1, ATTN_NORM);
else
sound (self, CHAN_WEAPON, "misc/water2.wav", 1, ATTN_NORM);
return;
}
// Fire a flame of type flame1.
sound (self, CHAN_WEAPON, "hknight/hit.wav", 1, ATTN_NORM);
flame = spawn();
flame.owner = self;
flame.movetype = MOVETYPE_FLYMISSILE;
flame.solid = SOLID_BBOX;
flame.classname = "flame1";
setmodel (flame, "progs/flame2.mdl");
setsize (flame, '0 0 0', '0 0 0');
setorigin (flame, self.origin + v_forward * 32 + v_up * (random()*16 - 8) + '0 0 16');
flame.effects = EF_DIMLIGHT;
flame.touch = Flame1Touch;
flame.think = SUB_RemoveTempEnt;
flame.nextthink = time + 1.5;
// set flame speed
makevectors (self.v_angle);
flame.velocity = (aim(self, 10000)* 400)+'0 0 32' + v_right * (random()*16 - 8);
};